package casa.depesos.app.com.http.req;


import casa.depesos.app.com.http.HttpReq;
import casa.depesos.app.com.http.Req;
import casa.depesos.app.com.http.ReqCallback;
import casa.depesos.app.com.http.bean.RelationBean;
import casa.depesos.app.com.http.bean.WhiteDataBean;
import casa.depesos.app.com.http.parser.RelationParser;
import casa.depesos.app.com.utils.Constant;
import okhttp3.FormBody;

public class RelationReq implements HttpReq<RelationBean> {
    @Override
    public void req(ReqCallback<RelationBean> callback) {//   /app/cust/queryRelative
        if (Constant.white) {
            new GetWhiteReq().req(new ReqCallback<WhiteDataBean>() {
                @Override
                public void callback(boolean success, WhiteDataBean bean) {
                    if (success && bean.isValid()) {
                        RelationBean tmp = new RelationBean();
                        tmp.list = bean.getData().list;
                        callback.callback(true, tmp);
                    } else {
                        callback.callback(false, null);
                    }
                }
            });
        } else {
            FormBody.Builder builder = new FormBody.Builder();
            Req.post("/app/professionalData/obtainKinshipInfo", getParam(), getHeader(), builder.build(), new RelationParser(), callback, this);
        }
    }
}
